<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="mytaglib" uri="http://www.zz.com/mytaglib" %>
<%@taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<html>
<head>
    <title>Login</title>
    <link rel="stylesheet" href="css/myStyle.css">
</head>
<body>
<div align="center">
    <span class="errMsg"><%
      if(request.getAttribute("errMsg") != null){
          out.println(request.getAttribute("errMsg")+"<br>");
      }
    %></span>
    <form method="post" action="LoginServlet">
        用户名: <input type="text" name="username"><br>
        密码: <input type="password" name="pass"><br>
        <input type="submit" value="登录">&nbsp;&nbsp;
        <input type="reset" value="重置">
    </form>
    <p>展示EL的用法</p>
    <table class="stable">
        <tr>
            <td>\${1+1}</td>
            <td>${1+1}</td>
        </tr>
        <tr>
            <td>\${1.2E4+1.5}</td>
            <td>${1.2E4+1.5}</td>
        </tr>
        <tr>
            <td>\${3/4}</td>
            <td>${3/4}</td>
        </tr>
        <tr>
            <td>\${3 div 4}</td>
            <td>${3 div 4}</td>
        </tr>
        <tr>
            <td>\${10%4}</td>
            <td>${10%4}</td>
        </tr>
        <tr>
            <td>\${10 mod 4}</td>
            <td>${10 mod 4}</td>
        </tr>
        <tr>
            <td>\${(1==2)?3:4}</td>
            <td>${(1==2)?3:4}</td>
        </tr>
    </table>
    <hr>
    <p>EL的内置对象</p>
    <%
        Cookie cookie = new Cookie("name","zzz");
        cookie.setMaxAge(30* 60);
        response.addCookie(cookie);

        pageContext.setAttribute("name","zzz");
    %>
    <form method="post" action="login.jsp">
        <label for="name">你的名字: </label>
        <input type="text" value="${param.name}" name="name" id="name"/>
        <input type="submit" value="submit">
    </form>
    <table class="stable">
        <tr>
            <td>\${param.name}</td>
            <td>${param.name}</td>
        </tr>
        <tr>
            <td>\${param["name"]}</td>
            <td>${param["name"]}</td>
        </tr>
        <tr>
            <td>\${header.host}</td>
            <td>${header.host}</td>
        </tr>
        <tr>
            <td>\${header["host"]}</td>
            <td>${header["host"]}</td>
        </tr>
        <tr>
            <td>\${initParam["sqlUser"]}</td>
            <td>${initParam["sqlUser"]}</td>
        </tr>
        <tr>
            <td>\${sessionScope.username}</td>
            <td>${sessionScope.username}</td>
        </tr>
        <tr>
            <td>\${cookie["name"]}</td>
            <td>${cookie["name"].value}</td>
        </tr>
        <tr>
            <td>\${pageScope["name"]}</td>
            <td>${pageScope["name"]}</td>
        </tr>
        <tr>
            <td>\${errMsg}</td>
            <td>${errMsg}</td>
        </tr>
        <tr>
            <td>\${mytaglib:reverse(header["host"])}</td>
            <td>${mytaglib:reverse(header["host"])}</td>
        </tr>
        <tr>
            <td>\${mytaglib:countChar(header["host"])}</td>
            <td>${mytaglib:countChar(header["host"])}</td>
        </tr>
    </table>
    <hr>
    <p>Tag File</p>
    <%
        List<String> list = new ArrayList<>();
        list.add("Java");
        list.add("Scala");
        list.add("Python");
        request.setAttribute("list",list);
    %>
    <tags:iterator bgColor="#99d99" cellColor="#9999cc" title="自定义标签文件迭代器"/>
    <p>用于/async提交</p>
    <form method="post" action="async">
        <input type="text" name="text">
        <input type="submit" value="submit">
    </form>
</div>
</body>
</html>
